package io.xccit.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.xccit.entity.User;
import io.xccit.mapper.IUserMapper;
import io.xccit.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *@author CH_ywx
 *@Date 2023-06-01
 *@Description UserService实现类
 */
@Service
public class UserServiceImpl extends ServiceImpl<IUserMapper, User> implements IUserService {

    @Autowired
    private IUserMapper userMapper;
    public User login(String name){
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("name",name);
        return userMapper.selectOne(queryWrapper);
    }

    @Override
    public List<String> getUserRoleByName(String principal) {
        return userMapper.getUserRolesByName(principal);
    }

    @Override
    public List<String> getUserRolePermissionsByRoleName(List<String> roleNames) {
        return userMapper.getUserRolePermissionsByRoleName(roleNames);
    }
}
